﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once

namespace gcmp 
{
    /// \brief Mesh操作返回的错误码
    ///
    enum class MeshOperateErrorCode : int32_t
    {
        Unknown = -1, ///< 未知
        NoError = 0, ///< 没有错误
        TriangleNormalChaos = 1, ///< 三角面法向混乱
        OtherError = 2 ///< 其他错误
    };

    /// \brief MeshBool操作返回的错误码
    ///
    enum class MeshBoolErrorCode : int32_t
    {
        BadParameter = -1,                   ///< 输入参数有误
        Success = 0,                        ///<Bool运算成功;
        Unknown = 1,                        ///<未知的情况;
        MeshNullPtr = 2,                    ///<Mesh指针为空;
        BoolOperationError = 3,             ///<Bool操作类型输入错误;
        DegenerateTriangle = 4,             ///<存在退化三角形;
        NextEdgeEmpty = 5,                  ///<下一条边为空导致成环失败;
        FailCalcNextEdge = 6,               ///<当前边和下一条边内外关系错误导致成环失败;
        FailCalcRing = 6,                   ///<搜环失败;
        FailCalcTriangulation = 7,          ///<三角剖分失败导致成体失败;
        IndexError = 8,                     ///<顶点映射指针为空;
        NotClosed = 9,                      ///<非封闭mesh，有重合顶点;
        FailCalcIntersectLine = 10,         ///<计算网格交线错误
        FailCutMesh = 11,                   ///<沿网格交线切割网格错误
        FailCalssifyMesh = 12,              ///<对切割后的网格分类错误
        OtherError = 13,                    ///<其他错误;
    };

    /// \brief Mesh开洞错误码
    ///
    enum class MeshOpenHoleErrorCode : int32_t
    {
        Unknown = -1, ///< 未知
        Success = 0, ///< 切割成功
        NullPtr = 1, ///< 指针为空;
        MeshEmpty = 2, ///< 三角网数据为空
        PolygonEmpty = 3, ///< 多边形数据为空
        PolygonError = 4, ///< 多边形中存在错误
        ProjectError = 5, ///< 投影矩阵计算错误
        TriangleError = 6, ///< 三角网存在非法（非流形或法向反向）三角面
        HoleBorderError = 7, ///< 开洞边缘无法上下应对，因为被一条线段分割的折线段数量不为2
        AddComplexEdge = 8, ///< 试图向结果模型中加入非流形边
        MeshCarveLoopError = 9 ///< 切割线无法获得错误
    };

    /*!
    * @enum MeshSimplifyErrorCode
    * @brief 简化函数错误码
    */
    enum class MeshSimplifyErrorCode : int32_t
    {
        Success = 0,               ///<简化成功
        PathError,                 ///<输入Mesh的路径错误
        MeshError,                 ///<Mesh文件中存在错误
        MeshEmpty,                 ///<Mesh为空
        RatioError,                ///<简化比参数输入错误
        FailCollapseSingleEdge,    ///<单边折叠失败
        FailCollectEdges,          ///<收集一环遍历对边失败
        FailCalcQMAT,              ///<计算Q矩阵失败
        FailCalcEegeQMAT,          ///<计算边Q矩阵失败
        FailCalcCentroid,          ///<计算三角网重心失败
        FailPreprocess,            ///<预处理失败
        MeshUVError,               ///<Mesh纹理信息错误
        FailComponentSimp,         ///<构件级简化算法失败
        FailPostProcess,           ///<后处理失败

        FailHashmapOvertime,       ///<求交次数过多退出
        FailBoxCollision,          ///<求交box冲突
        FailPolyShell,             ///<polyshell失败
        FailFixNormal,             ///<polyshell后修复法向失败
        Unknown,                   ///<未知状态
        NullPtr                    ///<空指针
    };

    /*!
    * @enum  MeshMeshIntErrorCode
    * @brief 网格求交线错误码
    */
    enum class MeshMeshIntErrorCode :int32_t
    {
        Success = 0,    ///< 求交线成功
        Error = 1,      ///< 求交线失败
        DistError = 2,  ///< 容差设置错误
        DistLarge = 3,  ///< 容差设置过大
        MeshEmpty = 4,  ///< 存在网格为空
        NullPtr = 5,    ///< 空指针
        Unknown = 6     ///<未知状态
    };

    /// \brief Brepbody转水密Mesh的错误码
    ///
    enum class MeshFromBrepBodyErrorCode : int32_t
    {
        Unknown = -1, ///< 未知
        Success = 0, ///< 成功
        BufferOverflow = 1, ///< 无法分配内存
        NoGeometry = 2, ///< 几何为空
        BadParameter = 3, ///< 输入参数有误
        CannotGetUV = 4, ///< 无法获取正确的UV
        NullPtr = 5 ///< 空指针
    };


    /*!
    * @enum  EnMeshShellSurroundBodyErrorCode
    * @brief 网格围合错误码
    */
    enum class MeshShellSurroundBodyErrorCode : int32_t
    {
        Unknown = -1,               ///< 未知
        Success = 0,                ///<围合成功
        BadParameter = 1,           ///< 输入参数有误
        StretchError = 2,           ///<拉伸成体错误
        MeshBoolError = 3,          ///<布尔运算错误
        ComponentSplitError = 4,    ///<连通性拆分错误
        MeshError = 5,              ///<输入网格数据错误
        NullPtr = 6                 ///< 空指针
    };
}
